<template>
    <my-layout>
        <template v-slot:header>
            <el-button size="small" @click='escEve'>返回</el-button>
        </template>
        <el-form
            size="small"
            label-width="100px"
            style="margin:1rem;padding-bottom: 1rem;">
            <el-row>
                <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                    <el-form-item label="供应商名字" prop="name">
                        <el-input v-model="supplierInfo.name" readonly></el-input>
                    </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                    <el-form-item label="合同" prop="contract">
                        <el-input style="width: calc(100% - 50px);" v-model="supplierInfo.contract" readonly>
                        </el-input>
                        <el-link style="width:50px; height:32px"  :href="'http://www.shuiyue.info:21000/public/contract/'+supplierInfo.contract" target="_blank">
                            <el-button size="small" type="primary" icon="el-icon-arrow-down"></el-button>
                        </el-link>
                    </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                    <el-form-item label="采购优先级" prop="level">
                        <el-input v-model="supplierInfo.level" readonly></el-input>
                    </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                    <el-form-item label="负责人" prop="director">
                        <el-input v-model="supplierInfo.director" readonly></el-input>
                    </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                    <el-form-item label="联系人" prop="contacts">
                        <el-input v-model="supplierInfo.contacts" readonly></el-input>
                    </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                    <el-form-item label="联系电话" prop="phone">
                        <el-input v-model="supplierInfo.phone" readonly></el-input>
                    </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                    <el-form-item label="成立日期" prop="estabilshment">
                        <el-input v-model="supplierInfo.establishment" readonly></el-input>
                    </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                    <el-form-item label="付款条件" prop="pay_condition">
                        <el-input v-model="supplierInfo.pay_condition" readonly></el-input>
                    </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                    <el-form-item label="设备状态" prop="devices_state">
                        <el-input v-model="supplierInfo.devices_state" readonly></el-input>
                    </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                    <el-form-item label="产地" prop="production">
                        <el-input v-model="supplierInfo.production" readonly></el-input>
                    </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                    <el-form-item label="信用码" prop="code">
                        <el-input v-model="supplierInfo.code" readonly></el-input>
                    </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                    <el-form-item label="开票地址" prop="ticket_address">
                        <el-input v-model="supplierInfo.ticket_address" readonly></el-input>
                    </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
                    <el-form-item label="审批信息" prop="name">
                        <el-table
                            :data="supplierInfo.PurApproveModels"
                            border>
                            <el-table-column
                                prop="approve_segment"
                                label="审批环节"
                                align="center"
                                width="120">
                            </el-table-column>
                            <el-table-column
                                prop="user_name"
                                label="审批人"
                                align="center"
                                width="120">
                            </el-table-column>
                            <el-table-column
                                prop="result"
                                label="审批结果"
                                align="center"
                                width="120">
                            </el-table-column>
                            <el-table-column
                                prop="time"
                                label="审批时间"
                                align="center"
                                width="180">
                            </el-table-column>
                            <el-table-column
                                prop="remark"
                                label="审批意见">
                            </el-table-column>
                        </el-table>
                    </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
                    <el-form-item label="备注" prop="remark">
                        <el-input style="width:50%" type="textarea" :autosize="{ minRows: 3, maxRows: 6}" v-model="supplierInfo.remark" readonly></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
        </el-form>
    </my-layout>
</template>
<script>
import { supplierInfoApi } from '@/apis/purchase'
import moment from 'moment'
export default {
    data(){
        return {
            supplierInfo:{}
        }
    },
    mounted(){
        supplierInfoApi(this.$route.query.id).then(d=>{
            if (d.code === 200){
                console.log(d)
                this.supplierInfo=d.data
                this.supplierInfo.contract=this.supplierInfo.contract.split('/')[3]
                this.supplierInfo.PurApproveModels.forEach(it => {
                    it.time = moment(it.time).format('YYYY[-]M[-]D H[:]M[:]SS ')
                    if (it.approve_segment =='Y'){
                        it.approve_segment="通过"
                    }else{
                        it.approve_segment="驳回"
                    }
                })
            }
        })
    },
    methods: {
        escEve(){
            this.$router.go(-1)
        }
    }
}
</script>